inherited fmRS_tabel: TfmRS_tabel
  Left = 439
  Top = 221
  Width = 485
  Height = 780
  Caption = #1058#1072#1073#1077#1083#1100
  Constraints.MinHeight = 780
  Constraints.MinWidth = 485
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  inherited sbBottom: TStatusBar
    Top = 718
    Width = 469
    Height = 24
  end
  inherited Panel1: TPanel
    Width = 469
    inherited BitBtn1: TBitBtn
      Left = 291
      Kind = bkCustom
    end
    inherited BitBtn2: TBitBtn
      Left = 379
      Kind = bkCustom
    end
  end
  object pcTabel: TcxPageControl [2]
    Left = 0
    Top = 45
    Width = 469
    Height = 673
    ActivePage = tsCopyTabel
    Align = alClient
    TabOrder = 2
    ClientRectBottom = 672
    ClientRectLeft = 1
    ClientRectRight = 468
    ClientRectTop = 21
    object tsTabel: TcxTabSheet
      Caption = #1058#1072#1073#1077#1083#1100
      ImageIndex = 0
      object Panel2: TPanel
        Left = 0
        Top = 0
        Width = 467
        Height = 353
        Align = alTop
        TabOrder = 0
        object Label7: TLabel
          Left = 8
          Top = 12
          Width = 134
          Height = 13
          Caption = #1044#1072#1090#1072' '#1087#1088#1086#1074#1077#1076#1077#1085#1080#1103' '#1079#1072#1085#1103#1090#1080#1103
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object Label1: TLabel
          Left = 160
          Top = 12
          Width = 113
          Height = 13
          Caption = #1042#1088#1077#1084#1103' '#1085#1072#1095#1072#1083#1072' '#1079#1072#1085#1103#1090#1080#1103
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object Label2: TLabel
          Left = 304
          Top = 12
          Width = 131
          Height = 13
          Caption = #1042#1088#1077#1084#1103' '#1086#1082#1086#1085#1095#1072#1085#1080#1103' '#1079#1072#1085#1103#1090#1080#1103
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object Label3: TLabel
          Left = 8
          Top = 68
          Width = 35
          Height = 13
          Caption = #1059#1089#1083#1091#1075#1072
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object Label4: TLabel
          Left = 8
          Top = 172
          Width = 68
          Height = 13
          Caption = #1058#1077#1084#1072' '#1079#1072#1085#1103#1090#1080#1103
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object Label5: TLabel
          Left = 8
          Top = 334
          Width = 75
          Height = 13
          Caption = #1042#1086#1089#1087#1080#1090#1072#1085#1085#1080#1082#1080':'
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object Label6: TLabel
          Left = 8
          Top = 119
          Width = 99
          Height = 13
          Caption = #1047#1072#1085#1103#1090#1080#1077' '#1087#1088#1086#1074#1077#1083'(-'#1072')'
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object eRSDATE: TcxDBDateEdit
          Left = 8
          Top = 30
          DataBinding.DataField = 'RSDATE'
          DataBinding.DataSource = dlgDS
          ParentFont = False
          Properties.DateButtons = [btnClear, btnToday]
          Properties.InputKind = ikMask
          Properties.SaveTime = False
          Properties.ShowTime = False
          Properties.WeekNumbers = True
          Properties.OnCloseUp = lcbPedagPropertiesCloseUp
          Style.Font.Charset = DEFAULT_CHARSET
          Style.Font.Color = clWindowText
          Style.Font.Height = -16
          Style.Font.Name = 'Tahoma'
          Style.Font.Style = [fsBold]
          Style.IsFontAssigned = True
          TabOrder = 0
          Width = 137
        end
        object eRSTIMEBEGIN: TcxDBTimeEdit
          Left = 160
          Top = 32
          DataBinding.DataField = 'RSTIMEBEGIN'
          DataBinding.DataSource = dlgDS
          ParentFont = False
          Properties.TimeFormat = tfHourMin
          Style.Font.Charset = DEFAULT_CHARSET
          Style.Font.Color = clWindowText
          Style.Font.Height = -16
          Style.Font.Name = 'Tahoma'
          Style.Font.Style = [fsBold]
          Style.IsFontAssigned = True
          TabOrder = 1
          Width = 121
        end
        object eRSTIMEEND: TcxDBTimeEdit
          Left = 304
          Top = 32
          DataBinding.DataField = 'RSTIMEEND'
          DataBinding.DataSource = dlgDS
          ParentFont = False
          Properties.TimeFormat = tfHourMin
          Style.Font.Charset = DEFAULT_CHARSET
          Style.Font.Color = clWindowText
          Style.Font.Height = -16
          Style.Font.Name = 'Tahoma'
          Style.Font.Style = [fsBold]
          Style.IsFontAssigned = True
          TabOrder = 2
          Width = 121
        end
        object ltvUsluga: TdxDBLookupTreeView
          Left = 4
          Top = 86
          Width = 297
          Height = 24
          CanSelectParents = False
          DropDownRows = 25
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -13
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentColor = False
          ParentFont = False
          TabOrder = 3
          TabStop = True
          Text = 'ltvUsluga'
          TreeViewColor = clWindow
          TreeViewCursor = crDefault
          TreeViewFont.Charset = DEFAULT_CHARSET
          TreeViewFont.Color = clWindowText
          TreeViewFont.Height = -11
          TreeViewFont.Name = 'MS Sans Serif'
          TreeViewFont.Style = []
          TreeViewIndent = 19
          TreeViewReadOnly = False
          TreeViewShowButtons = True
          TreeViewShowHint = False
          TreeViewShowLines = True
          TreeViewShowRoot = True
          TreeViewSortType = stNone
          TreeViewStateImages = DMInv.ilBJTree
          OnCloseUp = ltvUslugaCloseUp
          DisplayField = 'SDNAME'
          DividedChar = '.'
          ImageIndexField = 'SDISDELETE'
          ListSource = dsSD
          KeyField = 'SDID'
          ListField = 'SDNAME'
          Options = [trDBCanDelete, trDBConfirmDelete, trCanDBNavigate, trSmartRecordCopy, trCheckHasChildren]
          ParentField = 'SDPARID'
          RootValue = 0
          TextStyle = tvtsShort
          DataField = 'SDID'
          DataSource = dlgDS
        end
        object cxDBMemo1: TcxDBMemo
          Left = 8
          Top = 192
          DataBinding.DataField = 'RSTEMA'
          DataBinding.DataSource = dlgDS
          ParentFont = False
          Style.Font.Charset = DEFAULT_CHARSET
          Style.Font.Color = clWindowText
          Style.Font.Height = -16
          Style.Font.Name = 'Tahoma'
          Style.Font.Style = [fsBold]
          Style.IsFontAssigned = True
          TabOrder = 5
          Height = 89
          Width = 441
        end
        object lcbPedag: TcxDBLookupComboBox
          Left = 6
          Top = 134
          DataBinding.DataField = 'PID_PEDAG'
          DataBinding.DataSource = dlgDS
          ParentFont = False
          Properties.DropDownListStyle = lsEditList
          Properties.DropDownRows = 15
          Properties.KeyFieldNames = 'PID'
          Properties.ListColumns = <
            item
              Caption = #1060#1048#1054
              FieldName = 'PP'
            end
            item
              Caption = #1057#1090#1072#1090#1091#1089
              FieldName = 'SDNAME'
            end>
          Properties.ListSource = dsSotr
          Properties.MaxLength = 0
          Properties.OnCloseUp = lcbPedagPropertiesCloseUp
          Style.Font.Charset = DEFAULT_CHARSET
          Style.Font.Color = clBlack
          Style.Font.Height = -15
          Style.Font.Name = 'Tahoma'
          Style.Font.Style = []
          Style.Shadow = False
          Style.IsFontAssigned = True
          TabOrder = 4
          OnMouseDown = lcbPedagMouseDown
          Width = 446
        end
        object bFindChild: TcxButton
          Left = 8
          Top = 296
          Width = 441
          Height = 25
          Caption = #1055#1086#1080#1089#1082' '#1076#1077#1090#1077#1081
          Enabled = False
          TabOrder = 6
          OnClick = bFindChildClick
        end
      end
      object ToolBar2: TToolBar
        Left = 0
        Top = 353
        Width = 467
        Height = 29
        AutoSize = True
        BorderWidth = 2
        EdgeInner = esNone
        EdgeOuter = esNone
        Enabled = False
        Images = DMInv.ilActive
        TabOrder = 1
        TabStop = True
        Transparent = True
        object tbAddVosp: TToolButton
          Left = 0
          Top = 2
          Hint = #1044#1086#1073#1072#1074#1080#1090#1100' '#1090#1072#1073#1077#1083#1100
          Enabled = False
          ImageIndex = 30
          ParentShowHint = False
          ShowHint = True
          OnClick = tbAddVospClick
        end
        object tbDelVosp: TToolButton
          Left = 23
          Top = 2
          Hint = #1059#1076#1072#1083#1080#1090#1100' '#1090#1072#1073#1077#1083#1100
          Enabled = False
          ImageIndex = 29
          ParentShowHint = False
          ShowHint = True
          OnClick = tbDelVospClick
        end
      end
      object dbgRSTabel: TcxGrid
        Left = 0
        Top = 382
        Width = 467
        Height = 154
        Align = alClient
        Enabled = False
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clWindowText
        Font.Height = -13
        Font.Name = 'Tahoma'
        Font.Style = []
        ParentFont = False
        TabOrder = 2
        LookAndFeel.Kind = lfStandard
        object tvRSTabel: TcxGridDBTableView
          NavigatorButtons.ConfirmDelete = False
          NavigatorButtons.PriorPage.Visible = True
          NavigatorButtons.Next.Visible = True
          NavigatorButtons.Insert.Visible = True
          NavigatorButtons.Append.Visible = False
          NavigatorButtons.Edit.Visible = False
          NavigatorButtons.Post.Visible = True
          NavigatorButtons.Cancel.Visible = False
          NavigatorButtons.Refresh.Visible = False
          NavigatorButtons.SaveBookmark.Visible = False
          NavigatorButtons.GotoBookmark.Visible = False
          NavigatorButtons.Filter.Visible = False
          OnCellClick = tvRSTabelCellClick
          DataController.DataSource = dsVosp
          DataController.Summary.DefaultGroupSummaryItems = <>
          DataController.Summary.FooterSummaryItems = <
            item
              Kind = skCount
              FieldName = 'PID'
              Column = tvRSTabelPID
            end>
          DataController.Summary.SummaryGroups = <>
          OptionsBehavior.CellHints = True
          OptionsCustomize.ColumnFiltering = False
          OptionsData.Appending = True
          OptionsData.CancelOnExit = False
          OptionsView.CellEndEllipsis = True
          OptionsView.NoDataToDisplayInfoText = '<'#1053#1077#1090' '#1076#1072#1085#1085#1099#1093'>'
          OptionsView.CellAutoHeight = True
          OptionsView.CellTextMaxLineCount = 1
          OptionsView.ColumnAutoWidth = True
          OptionsView.Footer = True
          OptionsView.GroupByBox = False
          OptionsView.HeaderEndEllipsis = True
          OptionsView.Indicator = True
          Preview.Visible = True
          Styles.Header = DMInv.cxSiniyText
          object tvRSTabelColumn1: TcxGridDBColumn
            Caption = #8470
            OnGetDataText = tvRSTabelColumn1GetDataText
            Options.Editing = False
            Options.Filtering = False
            Options.Moving = False
            Options.Sorting = False
            Width = 40
          end
          object tvRSTabelPID: TcxGridDBColumn
            Caption = #1060#1048#1054
            DataBinding.FieldName = 'PP'
            PropertiesClassName = 'TcxButtonEditProperties'
            Properties.Buttons = <
              item
                Default = True
              end>
            Properties.ReadOnly = True
            Properties.OnButtonClick = tvRSTabelPIDPropertiesButtonClick
            Width = 176
          end
          object tvRSTabelOSN_PODR: TcxGridDBColumn
            Caption = #1054#1073#1088#1072#1079'. '#1087#1086#1076#1088'.'
            DataBinding.FieldName = 'OSN_PODR'
            Options.Editing = False
            Width = 144
          end
          object tvRSTabelRSPLEVEL: TcxGridDBColumn
            Caption = #1054#1094#1077#1085#1082#1072
            DataBinding.FieldName = 'RSPLEVEL'
            PropertiesClassName = 'TcxComboBoxProperties'
            Properties.Items.Strings = (
              '1'
              '2'
              '3'
              '4'
              '5')
            Width = 60
          end
          object tvRSTabelRSPNOTE: TcxGridDBColumn
            Caption = #1050#1086#1084#1084#1077#1085#1090'.'
            DataBinding.FieldName = 'RSPNOTE'
            Width = 92
          end
        end
        object cxGridLevel2: TcxGridLevel
          GridView = tvRSTabel
        end
      end
      object Panel3: TPanel
        Left = 0
        Top = 536
        Width = 467
        Height = 115
        Align = alBottom
        TabOrder = 3
        object Label8: TLabel
          Left = 16
          Top = 26
          Width = 150
          Height = 13
          Caption = #1040#1076#1084#1080#1085#1080#1089#1090#1088#1072#1090#1080#1074#1085#1099#1081' '#1088#1072#1073#1086#1090#1085#1080#1082
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clGray
          Font.Height = -11
          Font.Name = 'Tahoma'
          Font.Style = []
          ParentFont = False
        end
        object lcbAdm: TcxDBLookupComboBox
          Left = 14
          Top = 41
          DataBinding.DataField = 'PID_ADM'
          DataBinding.DataSource = dlgDS
          ParentFont = False
          Properties.DropDownListStyle = lsEditList
          Properties.DropDownRows = 15
          Properties.KeyFieldNames = 'PID'
          Properties.ListColumns = <
            item
              Caption = #1060#1048#1054
              FieldName = 'PP'
            end
            item
              Caption = #1057#1090#1072#1090#1091#1089
              FieldName = 'SDNAME'
            end>
          Properties.ListSource = dsSotr2
          Properties.MaxLength = 0
          Style.Font.Charset = DEFAULT_CHARSET
          Style.Font.Color = clBlack
          Style.Font.Height = -15
          Style.Font.Name = 'Tahoma'
          Style.Font.Style = []
          Style.Shadow = False
          Style.IsFontAssigned = True
          TabOrder = 0
          OnMouseDown = lcbPedagMouseDown
          Width = 443
        end
      end
    end
    object tsCopyTabel: TcxTabSheet
      Caption = #1050#1086#1087#1080#1103' '#1090#1072#1073#1077#1083#1103
      ImageIndex = 1
      object Panel4: TPanel
        Left = 0
        Top = 0
        Width = 467
        Height = 651
        Align = alClient
        TabOrder = 0
        object bFromFile: TcxButton
          Left = 1
          Top = 1
          Width = 465
          Height = 25
          Caption = #1044#1086#1073#1072#1074#1080#1090#1100'/'#1080#1079#1084#1077#1085#1080#1090#1100
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clWindowText
          Font.Height = -13
          Font.Name = 'Tahoma'
          Font.Style = [fsBold]
          ParentFont = False
          TabOrder = 0
          OnClick = bFromFileClick
          Align = alTop
          Glyph.Data = {
            76010000424D7601000000000000760000002800000020000000100000000100
            04000000000000010000CE0E0000D80E00001000000000000000000000000000
            80000080000000808000800000008000800080800000C0C0C000808080000000
            FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333
            3333333333387F3333333333333333333333333333387F333333333333344333
            3333333333387F3333333333333443333333333333387F333333333333344333
            3333333333387F3333333333333443333333333333387F333333333333344333
            3333387FFFFFFFFFFFFF3344444444444433387777777F777777334444444444
            4433388888887F8888883333333443333333333333387F333333333333344333
            3333333333387F3333333333333443333333333333387F333333333333344333
            3333333333387F33333333333334433333333333333877333333333333333333
            3333333333388833333333333333333333333333333333333333}
          NumGlyphs = 2
        end
        object PdfViewer1: TPdfViewer
          Left = 1
          Top = 26
          Width = 465
          Height = 624
          Align = alClient
          About = 'Synactis PDF Viewer version 1.0'
          AutoOpen = True
          Copies = 1
          EndPage = 0
          FitMode = vmFitBoxHorz
          LayoutMode = lmDontCare
          PageMode = pmStandard
          ShowPrintDialog = True
          ShowScrollBars = True
          ShowToolBar = True
          ShrinkToMargins = True
          StartPage = 1
        end
      end
    end
  end
  object Panel5: TPanel [3]
    Left = 8
    Top = 460
    Width = 441
    Height = 225
    Caption = 'Panel5'
    TabOrder = 3
    Visible = False
    object cxGrid1: TcxGrid
      Left = 1
      Top = 1
      Width = 439
      Height = 192
      Align = alTop
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -13
      Font.Name = 'Tahoma'
      Font.Style = []
      ParentFont = False
      TabOrder = 0
      LookAndFeel.Kind = lfStandard
      object cxGridDBTableView1: TcxGridDBTableView
        NavigatorButtons.ConfirmDelete = False
        NavigatorButtons.PriorPage.Visible = True
        NavigatorButtons.Next.Visible = True
        NavigatorButtons.Insert.Visible = True
        NavigatorButtons.Append.Visible = False
        NavigatorButtons.Edit.Visible = False
        NavigatorButtons.Post.Visible = True
        NavigatorButtons.Cancel.Visible = False
        NavigatorButtons.Refresh.Visible = False
        NavigatorButtons.SaveBookmark.Visible = False
        NavigatorButtons.GotoBookmark.Visible = False
        NavigatorButtons.Filter.Visible = False
        OnCellDblClick = cxGridDBTableView1CellDblClick
        DataController.DataSource = dsPoluchUslug
        DataController.Summary.DefaultGroupSummaryItems = <>
        DataController.Summary.FooterSummaryItems = <
          item
            Kind = skCount
            FieldName = 'PID'
          end>
        DataController.Summary.SummaryGroups = <>
        OptionsBehavior.CellHints = True
        OptionsCustomize.ColumnFiltering = False
        OptionsData.CancelOnExit = False
        OptionsData.Deleting = False
        OptionsData.DeletingConfirmation = False
        OptionsData.Editing = False
        OptionsData.Inserting = False
        OptionsView.CellEndEllipsis = True
        OptionsView.NoDataToDisplayInfoText = '<'#1053#1077#1090' '#1076#1072#1085#1085#1099#1093'>'
        OptionsView.CellAutoHeight = True
        OptionsView.CellTextMaxLineCount = 1
        OptionsView.ColumnAutoWidth = True
        OptionsView.GroupByBox = False
        OptionsView.HeaderEndEllipsis = True
        OptionsView.Indicator = True
        Preview.Visible = True
        Styles.Header = DMInv.cxSiniyText
        object cxGridDBTableView1PP: TcxGridDBColumn
          Caption = #1060#1048#1054
          DataBinding.FieldName = 'PP'
          Width = 213
        end
        object cxGridDBTableView1PODR: TcxGridDBColumn
          Caption = #1054#1073#1088#1072#1079'. '#1087#1086#1076#1088'.'
          DataBinding.FieldName = 'PODR'
          Width = 94
        end
        object cxGridDBTableView1PDATEBIRTH: TcxGridDBColumn
          Caption = #1044#1072#1090#1072' '#1088#1086#1078#1076'.'
          DataBinding.FieldName = 'PDATEBIRTH'
          Width = 108
        end
      end
      object cxGridLevel1: TcxGridLevel
        GridView = cxGridDBTableView1
      end
    end
    object b_cancel: TcxButton
      Left = 232
      Top = 196
      Width = 75
      Height = 25
      Caption = #1054#1090#1084#1077#1085#1072
      TabOrder = 1
      OnClick = b_cancelClick
    end
    object b_ok: TcxButton
      Left = 144
      Top = 196
      Width = 75
      Height = 25
      Caption = 'OK'
      TabOrder = 2
      OnClick = b_okClick
    end
  end
  inherited dlgDS: TDataSource
    OnDataChange = dlgDSDataChange
    Top = 8
  end
  object dsSD: TDataSource
    AutoEdit = False
    DataSet = qSD
    Left = 203
    Top = 174
  end
  object qSD: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT t1.*, SD1.SDISDELETE'
      'FROM'
      '('
      'WITH   recursive'
      '   tree (SDNAME, SDID, SDPARID, o)'
      
        '   AS (SELECT SD.SDNAME, SD.SDID, sd.SDPARID, CAST('#39#39' AS VARCHAR' +
        '(2048)) AS o FROM SYS_DIC SD'
      '      WHERE sd.SDPARID  = 20'
      '      UNION ALL'
      '      SELECT SD1.SDNAME, SD1.SDID, sd1.SDPARID, '#39' '#39' || o'
      ''
      '      FROM SYS_DIC SD1'
      '          INNER JOIN tree t '
      '           ON t.sdid = sd1.SDPARID)'
      ' SELECT  o || SDNAME AS SDNAME, SDID, SDPARID FROM tree t'
      ') AS t1'
      'INNER JOIN SYS_DIC sd1 ON sd1.SDID = t1.sdid'
      'order by 1'
      '')
    GeneratorField.Field = 'SDID'
    Left = 232
    Top = 176
    object qSDSDID: TIntegerField
      FieldName = 'SDID'
      ProviderFlags = []
    end
    object qSDSDPARID: TIntegerField
      FieldName = 'SDPARID'
      ProviderFlags = []
    end
    object qSDSDNAME: TIBStringField
      DisplayLabel = #1069#1083#1077#1084#1077#1085#1090
      FieldName = 'SDNAME'
      ProviderFlags = []
      Size = 2304
    end
    object qSDSDISDELETE: TIntegerField
      DisplayLabel = #1059#1076#1072#1083#1080#1090#1100'?'
      FieldName = 'SDISDELETE'
      Origin = '"SYS_DIC"."SDISDELETE"'
    end
  end
  object qVosp: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    AfterInsert = qVospAfterInsert
    BeforeOpen = qVospBeforeOpen
    CachedUpdates = True
    DataSource = dlgDS
    SQL.Strings = (
      'SELECT distinct RSP.*, sd.SDNAME AS osn_podr,'
      
        '(COALESCE(P.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P.PNAME,'#39' '#39')||'#39' '#39'||COA' +
        'LESCE(P.PPATRONYMIC,'#39' '#39')) AS PP'
      'FROM RS_PEOPLE RSP'
      'INNER JOIN PEOPLE P ON P.PID = RSP.PID'
      
        'LEFT OUTER JOIN deti_podrazd dp ON dp.pid = rsp.PID AND :data BE' +
        'TWEEN CAST(dp.dpdatein AS DATE) AND COALESCE(CAST(dp.dpdateout A' +
        'S DATE), current_date + 3650)'
      'LEFT OUTER JOIN sys_dic sd ON sd.sdid = dp.sdid'
      'WHERE RSP.RSID = :RSID'
      'AND RSP.RSPISDELETE IS NULL'
      'AND P.PISDELETE IS NULL')
    UpdateObject = quVosp
    Left = 176
    Top = 384
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'RSID'
        ParamType = ptUnknown
      end>
    object qVospRSID: TIntegerField
      FieldName = 'RSID'
      Origin = '"RS_PEOPLE"."RSID"'
      Required = True
    end
    object qVospPID: TIntegerField
      FieldName = 'PID'
      Origin = '"RS_PEOPLE"."PID"'
    end
    object qVospRSPLEVEL: TIntegerField
      FieldName = 'RSPLEVEL'
      Origin = '"RS_PEOPLE"."RSPLEVEL"'
    end
    object qVospRSPUSERENTER: TIBStringField
      FieldName = 'RSPUSERENTER'
      Origin = '"RS_PEOPLE"."RSPUSERENTER"'
      Size = 40
    end
    object qVospRSPTIMEENTER: TDateTimeField
      FieldName = 'RSPTIMEENTER'
      Origin = '"RS_PEOPLE"."RSPTIMEENTER"'
    end
    object qVospRSPUSEREDIT: TIBStringField
      FieldName = 'RSPUSEREDIT'
      Origin = '"RS_PEOPLE"."RSPUSEREDIT"'
      Size = 40
    end
    object qVospRSPTIMEEDIT: TDateTimeField
      FieldName = 'RSPTIMEEDIT'
      Origin = '"RS_PEOPLE"."RSPTIMEEDIT"'
    end
    object qVospRSPNOTE: TIBStringField
      FieldName = 'RSPNOTE'
      Origin = '"RS_PEOPLE"."RSPNOTE"'
      Size = 255
    end
    object qVospOSN_PODR: TIBStringField
      FieldName = 'OSN_PODR'
      Origin = '"SYS_DIC"."SDNAME"'
      Size = 255
    end
    object qVospTID: TIntegerField
      FieldName = 'TID'
      Origin = '"RS_PEOPLE"."TID"'
    end
    object qVospTARIF: TIBBCDField
      FieldName = 'TARIF'
      Origin = '"RS_PEOPLE"."TARIF"'
      Precision = 18
      Size = 2
    end
    object qVospPP: TIBStringField
      FieldName = 'PP'
      ProviderFlags = []
      Size = 767
    end
  end
  object quVosp: TIBUpdateSQL
    RefreshSQL.Strings = (
      'Select '
      '  RSID,'
      '  PID,'
      '  RSPLEVEL,'
      '  RSPUSERENTER,'
      '  RSPTIMEENTER,'
      '  RSPUSEREDIT,'
      '  RSPTIMEEDIT,'
      '  RSPNOTE,'
      '  RSPISDELETE,'
      '  RSOPLATIT,'
      '  RSOPLACHENO,'
      '  TID,'
      '  RSPCORRECTION,'
      '  TARIF,'
      '  OSN_PODR'
      'from RS_PEOPLE '
      'where'
      '  PID = :PID and'
      '  RSID = :RSID')
    ModifySQL.Strings = (
      'update RS_PEOPLE'
      'set'
      '  PID = :PID,'
      '  RSID = :RSID,'
      '  RSOPLACHENO = :RSOPLACHENO,'
      '  RSOPLATIT = :RSOPLATIT,'
      '  RSPCORRECTION = :RSPCORRECTION,'
      '  RSPISDELETE = :RSPISDELETE,'
      '  RSPLEVEL = :RSPLEVEL,'
      '  RSPNOTE = :RSPNOTE,'
      '  TARIF = :TARIF,'
      '  TID = :TID'
      'where'
      '  PID = :OLD_PID and'
      '  RSID = :OLD_RSID')
    InsertSQL.Strings = (
      'insert into RS_PEOPLE'
      
        '  (PID, RSID, RSOPLACHENO, RSOPLATIT, RSPCORRECTION, RSPISDELETE' +
        ', RSPLEVEL, '
      '   RSPNOTE, TARIF, TID)'
      'values'
      
        '  (:PID, :RSID, :RSOPLACHENO, :RSOPLATIT, :RSPCORRECTION, :RSPIS' +
        'DELETE, '
      '   :RSPLEVEL, :RSPNOTE, :TARIF, :TID)')
    DeleteSQL.Strings = (
      'delete from RS_PEOPLE'
      'where'
      '  PID = :OLD_PID and'
      '  RSID = :OLD_RSID')
    Left = 208
    Top = 384
  end
  object dsVosp: TDataSource
    DataSet = qVosp
    Left = 144
    Top = 376
  end
  object dsPoluchUslug: TDataSource
    DataSet = qPoluchUslug
    Left = 264
    Top = 461
  end
  object qPoluchUslug: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      
        'SELECT P.PID,(COALESCE(P.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P.PNAME,'#39 +
        ' '#39')||'#39' '#39'||COALESCE(P.PPATRONYMIC,'#39' '#39')) AS PP,'
      '    SD.SDNAME, sd1.SDNAME AS podr, P.PDATEBIRTH'
      'FROM PEOPLE P'
      'LEFT OUTER JOIN P_STATUS PS ON PS.PID = P.PID'
      
        'LEFT OUTER JOIN DETI_PODRAZD DP ON DP.PID = P.PID AND :data BETW' +
        'EEN CAST(dp.DPDATEIN AS DATE) AND COALESCE(CAST(dp.DPDATEOUT AS ' +
        'DATE), CURRENT_DATE+3650)'
      'LEFT OUTER JOIN SYS_DIC SD1 ON SD1.SDID = DP.SDID'
      'LEFT OUTER JOIN SYS_DIC SD ON SD.SDID = PS.SDID'
      'LEFT OUTER JOIN ('
      'SELECT RSP.PID, COUNT (RS.RSDATE) AS proveli'
      'FROM RENDERING_SERVICES RS'
      'INNER JOIN RS_PEOPLE RSP ON RSp.RSID = RS.RSID'
      'WHERE EXISTS'
      '('
      'SELECT S.SCID'
      'FROM SPEC_COND SC'
      '    INNER JOIN AGREEMENTS A ON a.AGID = SC.AGID'
      '    INNER JOIN AGR_POLUCH_USLUG APU ON APU.AGID = A.AGID'
      'INNER JOIN SERVICES S ON S.SCID = SC.SCID'
      'INNER JOIN SERVICES_TYPE ST ON st.STID = S.STID'
      
        'WHERE RS.RSDATE BETWEEN SC.SCDATEBEGIN AND COALESCE(sc.SCDATERAS' +
        'TORJ, sc.SCDATEEND)'
      
        'AND :data BETWEEN SC.SCDATEBEGIN AND COALESCE(sc.SCDATERASTORJ, ' +
        'sc.SCDATEEND)'
      
        'AND ST.STTYPE = 0 AND ST.STSDIDTABEL  = RS.SDID AND APU.PID = RS' +
        'P.PID'
      ')'
      'AND RS.SDID = :sdid'
      'AND RS.RSISDELETE IS NULL'
      'AND RSP.RSPISDELETE IS NULL'
      ''
      'GROUP BY 1'
      ') AS okaz_uslugi ON okaz_uslugi.PID = P.PID'
      'LEFT OUTER JOIN ('
      '    SELECT APU.PID, SUM(S.SCOUNT) AS zakazali'
      '    FROM SERVICES S'
      '    INNER JOIN SERVICES_TYPE ST ON ST.STID = S.STID'
      '    INNER JOIN SPEC_COND SC ON SC.SCID = S.SCID'
      '    INNER JOIN AGREEMENTS A ON a.AGID = SC.AGID'
      '    INNER JOIN AGR_POLUCH_USLUG APU ON APU.AGID = A.AGID'
      '    WHERE ST.STSDIDTABEL = :SDID'
      '    AND sc.scisdelete IS NULL'
      '    AND a.agisdelete IS NULL'
      '    AND ST.STTYPE = 0'
      
        '    AND :data BETWEEN SC.SCDATEBEGIN AND COALESCE(sc.SCDATERASTO' +
        'RJ, sc.SCDATEEND)'
      '    GROUP BY 1'
      ') AS zakaz_uslugi ON zakaz_uslugi.PID = P.PID'
      
        'INNER JOIN P_VIZIT PV ON PV.PID = P.PID AND PV.PVTIME_IN < :time' +
        '_begin AND COALESCE(PV.PVTIME_OUT, CURRENT_TIMESTAMP + 365) > :t' +
        'ime_end'
      'WHERE P.PISDELETE IS NULL'
      '    AND PS.SDID = 1246'
      
        '    AND  (zakaz_uslugi.zakazali - COALESCE(okaz_uslugi.proveli, ' +
        '0)) > 0'
      'UNION'
      '--'#1076#1086#1087#1086#1083#1085#1080#1090#1077#1083#1100#1085#1099#1077' '#1091#1089#1083#1091#1075#1080
      
        'SELECT P.PID, (COALESCE(P.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P.PNAME,' +
        #39' '#39')||'#39' '#39'||COALESCE(P.PPATRONYMIC,'#39' '#39')) AS PP,'
      '    SD.SDNAME, sd1.SDNAME AS podr, P.PDATEBIRTH'
      'FROM PEOPLE P'
      'LEFT OUTER JOIN P_STATUS PS ON PS.PID = P.PID'
      
        'LEFT OUTER JOIN DETI_PODRAZD DP ON DP.PID = P.PID AND :data BETW' +
        'EEN CAST(dp.DPDATEIN AS DATE) AND COALESCE(CAST(dp.DPDATEOUT AS ' +
        'DATE), CURRENT_DATE+3650)'
      'LEFT OUTER JOIN SYS_DIC SD1 ON SD1.SDID = DP.SDID'
      'LEFT OUTER JOIN SYS_DIC SD ON SD.SDID = PS.SDID'
      'LEFT OUTER JOIN ('
      'SELECT RSP.PID, COUNT (RS.RSDATE) AS proveli'
      'FROM RENDERING_SERVICES RS'
      'INNER JOIN RS_PEOPLE RSP ON RSp.RSID = RS.RSID'
      'INNER JOIN'
      '('
      
        'SELECT DISTINCT ST.STSDIDTABEL, APU.PID, SG.GPBEGINPERIOD, SG.GP' +
        'ENDPERIOD'
      'FROM SPEC_COND SC'
      '    INNER JOIN AGREEMENTS A ON a.AGID = SC.AGID'
      '    INNER JOIN AGR_POLUCH_USLUG APU ON APU.AGID = A.AGID'
      'INNER JOIN SERVICES S ON S.SCID = SC.SCID'
      'INNER JOIN SERVICES_TYPE ST ON st.STID = S.STID'
      'INNER JOIN SC_GRAFPLAT SG ON SG.SCID = SC.SCID'
      'WHERE :data BETWEEN SG.GPBEGINPERIOD AND SG.GPENDPERIOD'
      
        'AND :data BETWEEN SC.SCDATEBEGIN AND COALESCE(sc.SCDATERASTORJ, ' +
        'sc.SCDATEEND)'
      'AND ST.STTYPE = 2'
      
        ')  AS sel ON sel.pid = rsp.PID AND sel.STSDIDTABEL  = RS.SDID AN' +
        'D RS.RSDATE BETWEEN sel.GPBEGINPERIOD AND sel.GPENDPERIOD'
      'AND RS.SDID = :sdid'
      'WHERE RSP.RSPISDELETE IS NULL  AND RS.RSISDELETE IS NULL'
      'GROUP BY 1'
      ') AS okaz_uslugi ON okaz_uslugi.PID = P.PID'
      'LEFT OUTER JOIN ('
      '    SELECT APU.PID, SUM(ST.STMAXCOUNT) as STMAXCOUNT'
      '    FROM SERVICES S'
      '    INNER JOIN SERVICES_TYPE ST ON ST.STID = S.STID'
      '    INNER JOIN SPEC_COND SC ON SC.SCID = S.SCID'
      '    INNER JOIN AGREEMENTS A ON a.AGID = SC.AGID'
      '    INNER JOIN AGR_POLUCH_USLUG APU ON APU.AGID = A.AGID'
      '    WHERE ST.STSDIDTABEL = :SDID'
      '    AND sc.scisdelete IS NULL'
      '    AND a.agisdelete IS NULL'
      '    AND ST.STTYPE = 2'
      
        '    AND :data BETWEEN SC.SCDATEBEGIN AND COALESCE(sc.SCDATERASTO' +
        'RJ, sc.SCDATEEND)'
      '    GROUP BY 1'
      ') AS zakaz_uslugi ON zakaz_uslugi.PID = P.PID'
      
        'INNER JOIN P_VIZIT PV ON PV.PID = P.PID AND PV.PVTIME_IN < :time' +
        '_begin AND COALESCE(PV.PVTIME_OUT, CURRENT_TIMESTAMP + 365) > :t' +
        'ime_end'
      'WHERE P.PISDELETE IS NULL'
      '    AND PS.SDID = 1246'
      
        '    AND  (COALESCE(zakaz_uslugi.STMAXCOUNT, 0) - COALESCE(okaz_u' +
        'slugi.proveli, 0)) > 0'
      '--'#1090#1077#1085#1085#1080#1089
      'UNION'
      
        'SELECT P.PID, (COALESCE(P.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P.PNAME,' +
        #39' '#39')||'#39' '#39'||COALESCE(P.PPATRONYMIC,'#39' '#39')) AS PP,'
      '    SD.SDNAME, sd1.SDNAME AS podr, P.PDATEBIRTH'
      'FROM PEOPLE P'
      'LEFT OUTER JOIN P_STATUS PS ON PS.PID = P.PID'
      
        'LEFT OUTER JOIN DETI_PODRAZD DP ON DP.PID = P.PID AND :data BETW' +
        'EEN CAST(dp.DPDATEIN AS DATE) AND COALESCE(CAST(dp.DPDATEOUT AS ' +
        'DATE), CURRENT_DATE+3650)'
      'LEFT OUTER JOIN SYS_DIC SD1 ON SD1.SDID = DP.SDID'
      'LEFT OUTER JOIN SYS_DIC SD ON SD.SDID = PS.SDID'
      'LEFT OUTER JOIN ('
      'SELECT RSP.PID, COUNT (RS.RSDATE) AS proveli'
      'FROM RENDERING_SERVICES RS'
      'INNER JOIN RS_PEOPLE RSP ON RSP.RSID = RS.RSID'
      '    AND RS.RSISDELETE IS NULL'
      '    AND RSP.RSPISDELETE IS NULL'
      '    AND RS.SDID = IIF(cast(:sdid AS INTEGER) = 2087, 2087, -100)'
      'GROUP BY 1'
      ') AS okaz_uslugi ON okaz_uslugi.PID = P.PID'
      'LEFT OUTER JOIN ('
      '    SELECT APU.PID, SUM(S.SCOUNT) AS zakazali'
      '    FROM SERVICES S'
      '    INNER JOIN SERVICES_TYPE ST ON ST.STID = S.STID'
      '    INNER JOIN SPEC_COND SC ON SC.SCID = S.SCID'
      '    INNER JOIN AGREEMENTS A ON a.AGID = SC.AGID'
      '    INNER JOIN AGR_POLUCH_USLUG APU ON APU.AGID = A.AGID'
      
        '    WHERE ST.STSDIDTABEL = IIF(cast(:sdid AS INTEGER) = 2087, 20' +
        '87, -100)'
      '    AND sc.scisdelete IS NULL'
      '    AND a.agisdelete IS NULL'
      '    AND ST.STTYPE = 0'
      '    GROUP BY 1'
      ') AS zakaz_uslugi ON zakaz_uslugi.PID = P.PID'
      'WHERE P.PISDELETE IS NULL'
      '    AND PS.SDID = 1246'
      
        '    AND  (zakaz_uslugi.zakazali - COALESCE(okaz_uslugi.proveli, ' +
        '0)) > 0'
      'UNION'
      
        'SELECT P.PID, (COALESCE(P.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P.PNAME,' +
        #39' '#39')||'#39' '#39'||COALESCE(P.PPATRONYMIC,'#39' '#39')) AS PP,'
      '    SD.SDNAME, sd1.SDNAME AS podr, P.PDATEBIRTH'
      'FROM PEOPLE P'
      'LEFT OUTER JOIN P_STATUS PS ON PS.PID = P.PID'
      
        'LEFT OUTER JOIN DETI_PODRAZD DP ON DP.PID = P.PID AND :data BETW' +
        'EEN CAST(dp.DPDATEIN AS DATE) AND COALESCE(CAST(dp.DPDATEOUT AS ' +
        'DATE), CURRENT_DATE+3650)'
      'LEFT OUTER JOIN SYS_DIC SD1 ON SD1.SDID = DP.SDID'
      'LEFT OUTER JOIN SYS_DIC SD ON SD.SDID = PS.SDID'
      'INNER JOIN ('
      '    SELECT APU.PID'
      '    FROM SERVICES S'
      '    INNER JOIN SERVICES_TYPE ST ON ST.STID = S.STID'
      '    INNER JOIN SPEC_COND SC ON SC.SCID = S.SCID'
      '    INNER JOIN AGREEMENTS A ON a.AGID = SC.AGID'
      '    INNER JOIN AGR_POLUCH_USLUG APU ON APU.AGID = A.AGID'
      
        '    WHERE ST.STSDIDTABEL = IIF(cast(:sdid AS INTEGER) = 2087, 20' +
        '87, -100)'
      '    AND sc.scisdelete IS NULL'
      '    AND a.agisdelete IS NULL'
      '    AND ST.STTYPE = 2'
      '    AND :data BETWEEN SC.SCDATEBEGIN AND SC.SCDATEEND'
      '    GROUP BY 1'
      ') AS zakaz_uslugi ON zakaz_uslugi.PID = P.PID'
      'WHERE P.PISDELETE IS NULL'
      '    AND PS.SDID = 1246'
      '--'#1089#1090#1072#1088#1096#1080#1077
      'UNION'
      
        'SELECT P.PID, (COALESCE(P.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P.PNAME,' +
        #39' '#39')||'#39' '#39'||COALESCE(P.PPATRONYMIC,'#39' '#39')) AS PP,'
      '    SD.SDNAME, sd1.SDNAME AS podr, P.PDATEBIRTH'
      'FROM PEOPLE P'
      'LEFT OUTER JOIN P_STATUS PS ON PS.PID = P.PID'
      
        'LEFT OUTER JOIN DETI_PODRAZD DP ON DP.PID = P.PID AND :data BETW' +
        'EEN CAST(dp.DPDATEIN AS DATE) AND COALESCE(CAST(dp.DPDATEOUT AS ' +
        'DATE), CURRENT_DATE+3650)'
      'INNER JOIN'
      '('
      'SELECT t1.*, SD1.SDISDELETE'
      'FROM'
      '('
      'WITH   recursive'
      '   tree (SDNAME, SDID, SDPARID, o)'
      
        '   AS (SELECT SD.SDNAME, SD.SDID, sd.SDPARID, CAST('#39#39' AS VARCHAR' +
        '(2048)) AS o FROM SYS_DIC SD'
      '      WHERE sd.SDPARID IN (1412, 1413)'
      '      UNION ALL'
      '      SELECT SD1.SDNAME, SD1.SDID, sd1.SDPARID, '#39#39' || o'
      ''
      '      FROM SYS_DIC SD1'
      '          INNER JOIN tree t '
      '           ON t.sdid = sd1.SDPARID)'
      ' SELECT  o || SDNAME AS SDNAME, SDID, SDPARID FROM tree t'
      ') AS t1'
      'INNER JOIN SYS_DIC sd1 ON sd1.SDID = t1.sdid'
      'order by 1'
      ') AS sel ON SEL.sdid = DP.SDID'
      'LEFT OUTER JOIN SYS_DIC SD1 ON SD1.SDID = DP.SDID'
      'LEFT OUTER JOIN SYS_DIC SD ON SD.SDID = PS.SDID'
      'LEFT OUTER JOIN ('
      'SELECT RSP.PID, COUNT (RS.RSDATE) AS proveli'
      'FROM RENDERING_SERVICES RS'
      'INNER JOIN RS_PEOPLE RSP ON RSP.RSID = RS.RSID'
      '    AND RS.RSISDELETE IS NULL'
      '    AND RSP.RSPISDELETE IS NULL'
      '    AND RS.SDID = :sdid'
      'GROUP BY 1'
      ') AS okaz_uslugi ON okaz_uslugi.PID = P.PID'
      'LEFT OUTER JOIN ('
      '    SELECT APU.PID, SUM(S.SCOUNT) AS zakazali'
      '    FROM SERVICES S'
      '    INNER JOIN SERVICES_TYPE ST ON ST.STID = S.STID'
      '    INNER JOIN SPEC_COND SC ON SC.SCID = S.SCID'
      '    INNER JOIN AGREEMENTS A ON a.AGID = SC.AGID'
      '    INNER JOIN AGR_POLUCH_USLUG APU ON APU.AGID = A.AGID'
      '    WHERE ST.STSDIDTABEL = :sdid'
      '    AND sc.scisdelete IS NULL'
      '    AND a.agisdelete IS NULL'
      '    AND ST.STTYPE = 0'
      ''
      '    GROUP BY 1'
      ') AS zakaz_uslugi ON zakaz_uslugi.PID = P.PID'
      'WHERE P.PISDELETE IS NULL'
      '    AND PS.SDID = 1246'
      
        '    AND  (zakaz_uslugi.zakazali - COALESCE(okaz_uslugi.proveli, ' +
        '0)) > 0'
      'UNION'
      
        'SELECT P.PID, (COALESCE(P.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P.PNAME,' +
        #39' '#39')||'#39' '#39'||COALESCE(P.PPATRONYMIC,'#39' '#39')) AS PP,'
      '    SD.SDNAME, sd1.SDNAME AS podr, P.PDATEBIRTH'
      'FROM PEOPLE P'
      'LEFT OUTER JOIN P_STATUS PS ON PS.PID = P.PID'
      
        'LEFT OUTER JOIN DETI_PODRAZD DP ON DP.PID = P.PID AND :data BETW' +
        'EEN CAST(dp.DPDATEIN AS DATE) AND COALESCE(CAST(dp.DPDATEOUT AS ' +
        'DATE), CURRENT_DATE+3650)'
      'INNER JOIN'
      '('
      'SELECT t1.*, SD1.SDISDELETE'
      'FROM'
      '('
      'WITH   recursive'
      '   tree (SDNAME, SDID, SDPARID, o)'
      
        '   AS (SELECT SD.SDNAME, SD.SDID, sd.SDPARID, CAST('#39#39' AS VARCHAR' +
        '(2048)) AS o FROM SYS_DIC SD'
      '      WHERE sd.SDPARID IN (1412, 1413)'
      '      UNION ALL'
      '      SELECT SD1.SDNAME, SD1.SDID, sd1.SDPARID, '#39#39' || o'
      ''
      '      FROM SYS_DIC SD1'
      '          INNER JOIN tree t '
      '           ON t.sdid = sd1.SDPARID)'
      ' SELECT  o || SDNAME AS SDNAME, SDID, SDPARID FROM tree t'
      ') AS t1'
      'INNER JOIN SYS_DIC sd1 ON sd1.SDID = t1.sdid'
      'order by 1'
      ') AS sel ON SEL.sdid = DP.SDID'
      'LEFT OUTER JOIN SYS_DIC SD1 ON SD1.SDID = DP.SDID'
      'LEFT OUTER JOIN SYS_DIC SD ON SD.SDID = PS.SDID'
      'INNER JOIN ('
      '    SELECT APU.PID'
      '    FROM SERVICES S'
      '    INNER JOIN SERVICES_TYPE ST ON ST.STID = S.STID'
      '    INNER JOIN SPEC_COND SC ON SC.SCID = S.SCID'
      '    INNER JOIN AGREEMENTS A ON a.AGID = SC.AGID'
      '    INNER JOIN AGR_POLUCH_USLUG APU ON APU.AGID = A.AGID'
      '    WHERE ST.STSDIDTABEL = :sdid'
      '    AND sc.scisdelete IS NULL'
      '    AND a.agisdelete IS NULL'
      '    AND ST.STTYPE = 2'
      '    AND :data BETWEEN SC.SCDATEBEGIN AND SC.SCDATEEND'
      '    GROUP BY 1'
      ') AS zakaz_uslugi ON zakaz_uslugi.PID = P.PID'
      'WHERE P.PISDELETE IS NULL'
      '    AND PS.SDID = 1246'
      'ORDER BY 2'
      '')
    Left = 296
    Top = 461
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'SDID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'SDID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'time_begin'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'time_end'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'sdid'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'SDID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'time_begin'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'time_end'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'sdid'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'sdid'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'sdid'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'sdid'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'sdid'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'sdid'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end>
    object qPoluchUslugPID: TIntegerField
      FieldName = 'PID'
      Origin = '"PEOPLE"."PID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object qPoluchUslugPP: TIBStringField
      FieldName = 'PP'
      ProviderFlags = []
      Size = 767
    end
    object qPoluchUslugSDNAME: TIBStringField
      FieldName = 'SDNAME'
      Origin = '"SYS_DIC"."SDNAME"'
      Size = 255
    end
    object qPoluchUslugPODR: TIBStringField
      FieldName = 'PODR'
      Origin = '"SYS_DIC"."SDNAME"'
      Size = 255
    end
    object qPoluchUslugPDATEBIRTH: TDateField
      FieldName = 'PDATEBIRTH'
      Origin = '"PEOPLE"."PDATEBIRTH"'
    end
  end
  object qSotr: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      
        'SELECT P.PID, (COALESCE(P.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P.PNAME,' +
        #39' '#39')||'#39' '#39'||COALESCE(P.PPATRONYMIC,'#39' '#39')) AS PP,'
      '    SD.SDNAME, PS.SDID'
      'FROM PEOPLE P'
      'INNER JOIN P_STATUS PS ON PS.PID = P.PID'
      'INNER JOIN SYS_DIC SD ON SD.SDID = PS.SDID'
      'INNER JOIN'
      '('
      'SELECT t1.sdid'
      'FROM'
      '('
      'WITH   recursive'
      '   tree (SDNAME, SDID, SDPARID, o)'
      
        '   AS (SELECT SD.SDNAME, SD.SDID, sd.SDPARID, CAST('#39#39' AS VARCHAR' +
        '(2048)) AS o FROM SYS_DIC SD'
      '      WHERE sd.SDPARID  = 1470'
      '      UNION ALL'
      '      SELECT SD1.SDNAME, SD1.SDID, sd1.SDPARID, '#39' '#39' || o'
      ''
      '      FROM SYS_DIC SD1'
      '          INNER JOIN tree t '
      '           ON t.sdid = sd1.SDPARID)'
      ' SELECT  o || SDNAME AS SDNAME, SDID, SDPARID FROM tree t'
      ') AS t1'
      'WHERE t1.sdid <> 1783'
      ') as sotr on sotr.sdid = ps.SDID'
      'WHERE P.PISDELETE IS NULL'
      'UNION'
      'SELECT FIRST 1 NULL AS PID, NULL AS PP,'
      '    NULL AS SDNAME, NULL AS SDID'
      'FROM PEOPLE P'
      'ORDER BY 2')
    Left = 192
    Top = 552
    object qSotrPID: TIntegerField
      FieldName = 'PID'
      Origin = '"PEOPLE"."PID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
    end
    object qSotrPP: TIBStringField
      FieldName = 'PP'
      ProviderFlags = []
      Size = 767
    end
    object qSotrSDNAME: TIBStringField
      FieldName = 'SDNAME'
      Origin = '"SYS_DIC"."SDNAME"'
      Size = 255
    end
    object qSotrSDID: TIntegerField
      FieldName = 'SDID'
      Origin = '"P_STATUS"."SDID"'
    end
  end
  object dsSotr: TDataSource
    DataSet = qSotr
    Left = 160
    Top = 552
  end
  object qSotr2: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      
        'SELECT P.PID, (COALESCE(P.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P.PNAME,' +
        #39' '#39')||'#39' '#39'||COALESCE(P.PPATRONYMIC,'#39' '#39')) AS PP,'
      '    SD.SDNAME, PS.SDID'
      'FROM PEOPLE P'
      'INNER JOIN P_STATUS PS ON PS.PID = P.PID'
      'INNER JOIN SYS_DIC SD ON SD.SDID = PS.SDID'
      'INNER JOIN'
      '('
      'SELECT t1.sdid'
      'FROM'
      '('
      'WITH   recursive'
      '   tree (SDNAME, SDID, SDPARID, o)'
      
        '   AS (SELECT SD.SDNAME, SD.SDID, sd.SDPARID, CAST('#39#39' AS VARCHAR' +
        '(2048)) AS o FROM SYS_DIC SD'
      '      WHERE sd.SDPARID  = 1470'
      '      UNION ALL'
      '      SELECT SD1.SDNAME, SD1.SDID, sd1.SDPARID, '#39' '#39' || o'
      ''
      '      FROM SYS_DIC SD1'
      '          INNER JOIN tree t '
      '           ON t.sdid = sd1.SDPARID)'
      ' SELECT  o || SDNAME AS SDNAME, SDID, SDPARID FROM tree t'
      ') AS t1'
      'WHERE t1.sdid <> 1783'
      ') as sotr on sotr.sdid = ps.SDID'
      'WHERE P.PISDELETE IS NULL'
      'UNION'
      'SELECT FIRST 1 NULL AS PID, NULL AS PP,'
      '    NULL AS SDNAME, NULL AS SDID'
      'FROM PEOPLE P'
      'ORDER BY 2')
    Left = 248
    Top = 664
    object qSotr2PID: TIntegerField
      FieldName = 'PID'
      Origin = '"PEOPLE"."PID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
    end
    object qSotr2PP: TIBStringField
      FieldName = 'PP'
      ProviderFlags = []
      Size = 767
    end
    object qSotr2SDNAME: TIBStringField
      FieldName = 'SDNAME'
      Origin = '"SYS_DIC"."SDNAME"'
      Size = 255
    end
    object qSotr2SDID: TIntegerField
      FieldName = 'SDID'
      Origin = '"P_STATUS"."SDID"'
    end
  end
  object dsSotr2: TDataSource
    DataSet = qSotr2
    Left = 216
    Top = 664
  end
  object qRS_Scan: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    AfterInsert = qRS_ScanAfterInsert
    CachedUpdates = True
    DataSource = dlgDS
    SQL.Strings = (
      'SELECT RSS.*'
      'FROM RS_SCAN RSS'
      'WHERE RSS.RSID = :RSID')
    UpdateObject = quRS_Scan
    GeneratorField.Field = 'ASID'
    Left = 235
    Top = 256
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'RSID'
        ParamType = ptUnknown
      end>
    object qRS_ScanRSSPICTURE: TBlobField
      FieldName = 'RSSPICTURE'
      Origin = '"RS_SCAN"."RSSPICTURE"'
      ProviderFlags = [pfInUpdate]
      Size = 8
    end
    object qRS_ScanRSID: TIntegerField
      FieldName = 'RSID'
      Origin = '"RS_SCAN"."RSID"'
      Required = True
    end
  end
  object quRS_Scan: TIBUpdateSQL
    RefreshSQL.Strings = (
      'Select '
      '  RSID,'
      '  RSSPICTURE,'
      '  RSSUSERENTER,'
      '  RSSTIMEENTER,'
      '  RSSUSEREDIT,'
      '  RSSTIMEEDIT'
      'from RS_SCAN '
      'where'
      '  RSID = :RSID')
    ModifySQL.Strings = (
      'update RS_SCAN'
      'set'
      '  RSID = :RSID,'
      '  RSSPICTURE = :RSSPICTURE,'
      '  RSSTIMEEDIT = :RSSTIMEEDIT,'
      '  RSSTIMEENTER = :RSSTIMEENTER,'
      '  RSSUSEREDIT = :RSSUSEREDIT,'
      '  RSSUSERENTER = :RSSUSERENTER'
      'where'
      '  RSID = :OLD_RSID')
    InsertSQL.Strings = (
      'insert into RS_SCAN'
      
        '  (RSID, RSSPICTURE, RSSTIMEEDIT, RSSTIMEENTER, RSSUSEREDIT, RSS' +
        'USERENTER)'
      'values'
      
        '  (:RSID, :RSSPICTURE, :RSSTIMEEDIT, :RSSTIMEENTER, :RSSUSEREDIT' +
        ', :RSSUSERENTER)')
    DeleteSQL.Strings = (
      'delete from RS_SCAN'
      'where'
      '  RSID = :OLD_RSID')
    Left = 267
    Top = 256
  end
  object odScan: TOpenDialog
    Filter = 'PDF|*.pdf'
    InitialDir = #1089':\'
    Left = 120
    Top = 200
  end
  object qTarif: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT distinct t.TID, t.TTARIF'
      'FROM DOP_USL_TARIFFS T'
      'WHERE T.SDID = :sdid and t.pid = :pid'
      '    AND :data BETWEEN t.TDATEBEGIN AND t.TDATEEND')
    Left = 377
    Top = 154
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'sdid'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'pid'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'data'
        ParamType = ptUnknown
      end>
    object qTarifTID: TIntegerField
      FieldName = 'TID'
      Origin = '"DOP_USL_TARIFFS"."TID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object qTarifTTARIF: TIBBCDField
      FieldName = 'TTARIF'
      Origin = '"DOP_USL_TARIFFS"."TTARIF"'
      Precision = 18
      Size = 2
    end
  end
end
